package com.zhj.common.db.mysql.config;

import com.zhj.common.db.mysql.aop.PageAOP;
import com.zhj.common.db.mysql.aop.WebPageAOP;
import com.zhj.common.db.mysql.plugins.PagePlugins;
import com.zhj.common.db.mysql.plugins.PrintSQLPlugins;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author zhj
 */
@Configuration
@MapperScan("com.zhj.data.mapper")
@EnableTransactionManagement
public class DBAutoConfiguration {

    @Bean
    @ConditionalOnProperty(value = "zhj.plugins.printSql.enable", havingValue = "true", matchIfMissing = false)
    public PrintSQLPlugins getPrintSQLPlugins(){
        return new PrintSQLPlugins();
    }

    @Bean
    public PagePlugins getPagePlugins(){
        return new PagePlugins();
    }

    @Bean
    public WebPageAOP getWebPageAOP(){
        return new WebPageAOP();
    }

    @Bean
    public PageAOP getPageAOP(){
        return new PageAOP();
    }
}
